package com.zb.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjWorkSpareReceipt;
import com.zb.mapper.ZjWorkSpareReceiptMapper;
import com.zb.service.ZjWorkSpareReceiptService;
import com.zb.vo.WorkSpareVo;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 工单备件收货信息表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2023-10-26
 */
@Service
public class ZjWorkSpareReceiptServiceImpl extends ServiceImpl<ZjWorkSpareReceiptMapper, ZjWorkSpareReceipt> implements ZjWorkSpareReceiptService {

    // 新增、修改备件收货地址
    @Override
    public void save(Long custAccId, Long id, WorkSpareVo workSpareVo) {
        ZjWorkSpareReceipt receipt = new ZjWorkSpareReceipt();
        BeanUtil.copyProperties(workSpareVo, receipt);
        receipt.setId(id);
        if (null != this.getById(id)) {
            this.updateById(receipt);
            return;
        }
        receipt.setCustAccId(custAccId);
        this.save(receipt);
    }
}
